package com.zhangchuchu.neohealth.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhangchuchu.neohealth.entity.ChatMessage;
import com.zhangchuchu.neohealth.mapper.ChatMessageMapper;
import com.zhangchuchu.neohealth.service.ChatMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatMessageServiceImpl extends ServiceImpl<ChatMessageMapper, ChatMessage> implements ChatMessageService {

    @Autowired
    ChatMessageMapper chatMessageMapper;

    @Override
    public List<ChatMessage> GetLastMessagesBySender(String recipient) {
        return chatMessageMapper.GetLastMessagesBySender(recipient);
    }

    @Override
    public List<ChatMessage> getChatHistory(String sender, String recipient) {
        return chatMessageMapper.GetChatMessages(sender,recipient);
    }

    @Override
    public void saveMessage(ChatMessage message) {
        chatMessageMapper.insert(message);
    }

    @Override
    public void markMessagesAsRead(String sender, String recipient) {
        baseMapper.markMessagesAsRead(sender,recipient);
    }
}